package br.com.colegio.carga;


public class LeitorOFX {
/*
	public static void lerOFX(InputStream is){
		try {
			ResponseEnvelope e = (new AggregateUnmarshaller<ResponseEnvelope>(ResponseEnvelope.class)).unmarshal(is);
			BankingResponseMessageSet ms = (BankingResponseMessageSet) e.getMessageSet(MessageSetType.banking);
			List<BankStatementResponseTransaction> rs = ms.getStatementResponses();

			for(BankStatementResponseTransaction r : rs) {
				BankStatementResponse m = r.getMessage();
				String banco = m.getAccount().getBankId();
				String agencia = m.getAccount().getBranchId();
				String conta = m.getAccount().getAccountNumber();
				AccountType acct_type = m.getAccount().getAccountType();
				double saldo = m.getLedgerBalance().getAmount();
				Date saldoData = m.getLedgerBalance().getAsOfDate();

				System.out.println(banco + "\t" + agencia + "\t"
						+ conta + "\t" + acct_type + "\t"
						+ saldo + "\t" + saldoData + "\t");

				for(Transaction t : m.getTransactionList().getTransactions()){
					String tipo  = t.getTransactionType().name();
					Date   data  = t.getDatePosted();
					double valor = t.getAmount();
					String id    = t.getId();
					String desc  = t.getMemo();
					
					FinanceiroLancamento fl = new FinanceiroLancamento();
					fl.setData(data);
					fl.setHistoricoBanco(desc);
					fl.setNumeroDocumentoBanco(id);
					fl.setTipo(tipo);
					fl.setValor(valor);

					System.out.println(tipo + "\t" + data + "\t" + valor + "\t" + id + "\t" + desc);
				}
			}
		}
		catch(OFXParseException e){
			e.printStackTrace();
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}

	public static void main(String[] args){

		try {
//			LeitorOFX.lerOFX(new FileInputStream("E:/_escola/conta-corrente/extrato/2012-12.ofx"));

			String sf = FileUtil.fileToString(new FileReader("E:/_escola/conta-corrente/extrato/2012-12.ofx"));
			LeitorOFX.lerOFX(new ByteArrayInputStream(sf.getBytes()));
		} catch(FileNotFoundException e){
			e.printStackTrace();
		} catch(IOException e){
			e.printStackTrace();
		}
	}
*/
}
